package com.lanou.myim.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.easemob.chat.EMChatManager;
import com.easemob.chat.EMGroupManager;
import com.easemob.exceptions.EaseMobException;
import com.lanou.myim.R;


/**
 * Created by dllo on 16/3/9.
 */
public class AddGroupActivity extends BaseActivity {
    private EditText add_group_name;
    private EditText add_group_brief;
    private Button add_group_found;
    private String[] members;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_group);
        add_group_name = (EditText) findViewById(R.id.add_group_name);
        add_group_brief = (EditText) findViewById(R.id.add_group_brief);
        add_group_found = (Button) findViewById(R.id.add_group_found);
        String account = EMChatManager.getInstance().getCurrentUser();

        members = new String[]{account};

        add_group_found.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            EMGroupManager.getInstance().createPublicGroup(add_group_name.getText().toString(), add_group_brief.getText().toString(), null, false);
                        } catch (EaseMobException e) {
                            e.printStackTrace();
                        }

                    }
                }).start();

                Toast.makeText(AddGroupActivity.this, "创建成功", Toast.LENGTH_SHORT).show();

            }
        });


    }
}
